class CodeResponse {
  final List<CodeData>? data;
  final int resultCode;
  final String resultMsg;
  final int? queryCount;
  final dynamic resultMsgEx;

  CodeResponse({
    this.data,
    this.queryCount,
    this.resultMsgEx,
    required this.resultCode,
    required this.resultMsg,
  });

  factory CodeResponse.fromJson(Map<String, dynamic> json) {
    return CodeResponse(
      data: (json['data'] as List<dynamic>?)
          ?.map((e) => CodeData.fromJson(e as Map<String, dynamic>))
          .toList(),
      resultCode: json['resultCode'] ?? 0,
      resultMsg: json['resultMsg'] ?? "",
      queryCount: json['queryCount'] ?? 0,
      resultMsgEx: json['resultMsgEx'],
    );
  }

  Map<String, dynamic> toJson() {
    return {
      'data': data?.map((e) => e.toJson()).toList(),
      'resultCode': resultCode,
      'resultMsg': resultMsg,
      'queryCount': queryCount,
      'resultMsgEx': resultMsgEx,
    };
  }
}

class CodeData {
  final String label;
  final String value;

  CodeData({
    required this.label,
    required this.value,
  });

  factory CodeData.fromJson(Map<String, dynamic> json) {
    return CodeData(
      label: json['label'] ?? "",
      value: json['value'] ?? "",
    );
  }

  Map<String, dynamic> toJson() {
    return {
      'label': label,
      'value': value,
    };
  }
}
